# -*- coding: utf-8 -*-
__author__ = 'BuddyHolly'

import pptx
from pptx import Presentation


# =================
# *** 图片信息类 ***
# =================

# info_list: [slide_id, shape_id]
class InfoPic:

    def __init__(self, ppt_path):
        self.prs = Presentation(ppt_path)
        self.info_list = []

    # 通过判断isinstance是否为pptx.shapes.picture.Picture，判断是否提取图片信息
    def get_info(self):
        self.info_list = []
        for slide_id, slide in enumerate(self.prs.slides):
            for shape_id, shape in enumerate(slide.shapes):
                if isinstance(shape, pptx.shapes.picture.Picture):
                    self.info_list.append([slide_id, shape_id])
        # 返回info_list，其中内容格式为[slide_id, shape_id]
        return self.info_list
